package com.lin.controller;


import com.lin.entity.Menu;
import com.lin.reponse.Result;
import com.lin.service.MenuService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author Lin
 * @since 2022-03-01
 */
@RestController
@RequestMapping("/menu")
@CrossOrigin
public class MenuController {

    @Resource
    private MenuService menuService;

    /**
     * 加载菜单树
     *
     * @return {@link Result}
     */
    @ApiOperation(value = "加载菜单树",tags = "获取所有菜单树")
    @GetMapping("/tree")
    public Result tree(){
        List<Menu> menuTree=menuService.findMenuTree();
        return Result.ok().data("tree",menuTree);
    }

}

